package models

import (
	"gorm.io/gorm"
	"time"
)

//	Id  int64 `gorm:"column:id;type:int(11);index:unique;not null;comment:Id" json:"id"`
type BaseModel struct {
	CreatedAt time.Time `gorm:"column:add_at" json:"created_at"`
	UpdatedAt time.Time `gorm:"column:update_at" json:"updated_at"`
	DeletedAt gorm.DeletedAt
	IsDeleted *bool
}

// gorm提供的官方使用
func Paginate(page, limit int64) func(db *gorm.DB) *gorm.DB {
	return func(db *gorm.DB) *gorm.DB {
		offset := (page - 1) * limit
		return db.Offset(int(offset)).Limit(int(limit))
	}
}
